<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${projectName}</title>
<script type="text/javascript"
	src='<c:url value="/js/boot.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script src="<c:url value='/js/jquery.ui.widget.js'></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>"></script>
<script src="<c:url value='/js/jquery.fileupload.js'></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>"></script>
<script src="<c:url value='/js/server/rqfCommon.js'></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>"></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style type="text/css">
body {
	height: 100%;
}

.fieldTitle {
	width: 100px !important;
}

.mini-tabs-leftButton, .mini-tabs-rightButton {
	display: none;
}

.mini-tabs-scrollCt {
	border-top: 0;
}

.mini-tabs-bodys {
	padding: 0;
}

.headerpan {
	margin-left: 10px;
	font-size: 14px;
	font-weight: bold;
}
#UserPhoto{
	background-image: url('<c:url value="/share/images/test.jpg"></c:url>');
	background-size:150px 210px;
	width:150px;
	height: 210px;
	vertical-align: middle;
	margin-left:auto; 
	margin-right:auto;
}
.photoStyle{
	background-size:150px 210px;
	width:150px;
	height: 210px;
	vertical-align: middle;
	margin-left:auto; 
	margin-right:auto;
}
.cardStyle{
	background-size:210px 120px;
	width:210px;
	height: 120px;
	vertical-align: middle;
	margin-left:auto; 
	margin-right:auto;
}

#headimg {
	margin-left:auto; 
	margin-right:auto;
	width: 150px;
	height: 210px;
	/* border:1px solid #ccc; */
	background-size: 100%;
}

.cardimg {
	margin-left:auto; 
	margin-right:auto;
	width: 100%;
	height: 120px;
	/* border:1px solid #ccc; */
	background-size: 100%;
}

#change_head_btn,#id_card_a,#id_card_b {
	width: 75px;
	height: 20px;
	color: white;
	text-align: center;
	margin-left: auto;
	margin-right: auto;
	margin-top: 5px;
}
#change_psw_btn {
	width: 75px;
	height: 20px;
	color: white;
	text-align: center;
	margin-left: 500px;
	margin-right: auto;
	margin-top: 10px;
}

.file {
	position: relative;
	display: inline-block;
	background: #1e519f;
	/*border: 1px solid #99D3F5;*/
	border-radius: 4px;
	/* padding: 4px 12px; */
	overflow: hidden;
	color: #1E88C7;
	text-decoration: none;
	text-indent: 0;
	line-height: 20px;
	cursor: pointer !important;
}
.file input {
	position: absolute;
	font-size: 100px;
	right: 0;
	top: 0;
	opacity: 0;
	cursor: pointer;
}

.file:hover {
	background: #ccc;
	text-decoration: none;
}
.id_card_style{
	width: 100%;
	height: 140px;
}
.formContent{
	margin-left: 50px;
}

</style>
<script type="text/javascript">
	var sexData = [ {
		id : 1,
		text : "男"
	}, {
		id : 0,
		text : "女"
	} ];
	var natureData = [ {
		id : 1,
		text : "长期"
	}, {
		id : 0,
		text : "短期"
	} ];
</script>
</head>
<body>
	<form id="dataForm">
		<div class="formContent">
			<input id="OrgNo" name="OrgNo" class="mini-hidden"
				style="width: 100%;" />
			<input id="EmployId" name="EmployId" class="mini-hidden"
				style="width: 100%;" />
			<table class="formContentTable type1" id="type1">
				<span class="headerpan type1">基本信息<a href="javascript:;" class="file" id="change_psw_btn">修改密码</a></span>
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">身份证号</td>
					<td class="fieldContent" colspan="2"><input id="CardID"
						name="CardID" class="mini-textbox" style="width: 100%;"
						required="true" value="${CardID}"/></td>
					<td class="photoTd" rowspan="8"><div id="headimg"
							style="border: 1px solid #ccc;"><a href="javascript:;">
							<img src="<c:url value='/share/images/photo_1.jpg'></c:url>"
								id="imgUrl" alt="" class="photoStyle" /></a>
						</div>
						<a href="javascript:;" class="file" id="change_head_btn">上传照片
							<input
							accept="image/png,image/bmp,image/jpeg,image/gif,image/jpg"
							name="file" type="file" id="fileId" />
					</a></td>
					<!-- <td class="photoTd" rowspan="8"><a href="javascript:;"><div
						id="UserPhoto" onclick="javascript:addPhoto()"></div></a></td> -->
				</tr>
				<tr>
					<td class="fieldTitle">姓名</td>
					<td class="fieldContent" colspan="2"><input id="UserName"
						name="UserName" class="mini-textbox" style="width: 100%;"
						required="true" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">性别</td>
					<td class="fieldContent" colspan="2"><input name="Sex"
						required="false" class="mini-combobox" id="Sex"
						style="width: 100%;" textField="text" valueField="id"
						data="sexData" showNullItem="true" 
						emptyText="保密" allowInput="true" onValueChanged="" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">出生日期</td>
					<td class="fieldContent" colspan="2"><input id="BirthDay"
						enabled="true" name="BirthDay" class="mini-datepicker"
						style="width: 100%;" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">原户籍地</td>
					<td class="fieldContent" colspan="2"><input id="Registry"
						name="Registry" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">现居住地</td>
					<td class="fieldContent" colspan="2"><input id="Residence"
						name="Residence" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">手机号码</td>
					<td class="fieldContent" colspan="2"><input id="PhoneNo"
						name="PhoneNo" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">邮箱</td>
					<td class="fieldContent" colspan="2"><input id="Email"
						name="Email" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">紧急联系人</td>
					<td class="fieldContent" colspan="3"><textarea id="Linkman"
							name="Linkman" style="width: 100%; height: 80px;"
							required="false" class="mini-textarea" emptyText="输入紧急联系人及联系方式"></textarea></td>
				</tr>
				<tr>
					<td class="fieldTitle">身份证正面</td>
					<td class="id_card_style"><div class="cardimg"
							style="border: 1px solid #ccc;"><a href="javascript:;">
							<img src="<c:url value='/share/images/id_cardA_1.jpg'></c:url>"
								id="imgUrlA" alt="" class="cardStyle" /></a>
						</div>
						<a href="javascript:;" class="file" id="id_card_a">上传
							<input
							accept="image/png,image/bmp,image/jpeg,image/gif,image/jpg"
							name="fileA" type="file" id="fileIdA" />
					</a></td>
					<td class="fieldTitle">身份证反面</td>
					<td class="id_card_style"><div class="cardimg"
							style="border: 1px solid #ccc;"><a href="javascript:;">
							<img src="<c:url value='/share/images/id_cardB_1.jpg'></c:url>"
								id="imgUrlB" alt="" class="cardStyle" /></a>
						</div>
						<a href="javascript:;" class="file" id="id_card_b">上传
							<input
							accept="image/png,image/bmp,image/jpeg,image/gif,image/jpg"
							name="fileB" type="file" id="fileIdB" />
					</a></td>
				</tr>
			</table>
			<table class="formContentTable type1" id="type2">
				<span class="headerpan type1">入职登记</span>
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">企业名称</td>
					<td class="fieldContent" colspan="3"><input id="OrgName"
						name="OrgName" class="mini-textbox" style="width: 100%;"
						required="true" enabled="false"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">来源</td>
					<td class="fieldContent"><input name="Source" 
						id="Source" required="false" class="mini-combobox"
						style="width: 100%;" textField="UserName" valueField="CardID"
						url="" showNullItem="true" allowInput="false" onvalidation="onComboValidation"
						onvaluechanged="" /></td>
					<td class="fieldTitle">来源分类</td>
					<td class="fieldContent"><input name="SourceType"
						id="SourceType" required="false" class="mini-combobox"
						style="width: 100%;" textField="SourceType" valueField="TypeNo"
						url="<c:url value='/common/type/source_type'></c:url>" showNullItem="false" allowInput="false" 
						onvaluechanged="" /></td>
				</tr>
				<tr>
					<td class="fieldTitle">性质</td>
					<td class="fieldContent"><input name="Nature"
						id="Nature" required="false" class="mini-combobox"
						style="width: 100%;" textField="text" valueField="id"
						data="natureData" showNullItem="false" allowInput="false"
						onvaluechanged="" /></td>
					<td class="fieldTitle">工种</td>
					<td class="fieldContent"><input name="EmployType"
						id="EmployType" required="false" class="mini-combobox"
						style="width: 100%;" textField="EmployType" valueField="TypeNo"
						url="<c:url value='/common/type/employ_type'></c:url>" showNullItem="false" allowInput="false"
						onvaluechanged="" /></td>
				</tr>
			</table>
			<table class="formContentTable type1" id="type3">
				<span class="headerpan type1">资金账号</span>
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
				<tr>
					<td class="fieldTitle">支付宝账号</td>
					<td class="fieldContent" colspan="3"><input id="AlipayNo"
						name="AlipayNo" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">微信账号</td>
					<td class="fieldContent" colspan="3"><input id="WechartNo"
						name="WechartNo" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
				<tr>
					<td class="fieldTitle">银行卡号</td>
					<td class="fieldContent" colspan="3"><input id="BankNo"
						name="BankNo" class="mini-textbox" style="width: 100%;"
						required="false" enabled="true"/></td>
				</tr>
			</table>
			<table class="formContentTable type1" id="type4">
				<span class="headerpan type1">其他信息</span>
				<tr>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
					<th class="fieldTitle"></th>
					<th class="fieldContent"></th>
				</tr>
			</table>
		</div>
	</form>

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		
		var configStr = "${configStr}";
		var action = "${action}";
		var rootPath = "${rootPath}";
		var id = "${id}";
		var cardId = "${cardId}";
		var fileServer = "${fileServer}";
		
		var dataOri = null;
		
		var CardID = mini.get("CardID");
		var Source = mini.get("Source");
		var OrgNo = mini.get("OrgNo");
		var OrgName = mini.get("OrgName");
		
		
		if(configStr){
			$('#type4').append(configStr);
		}else{
			$('#type4').hide();
		}
		

		var form = new mini.Form("dataForm");
		labelModel(form);

		SetFormData();

		function SetFormData() {
			if (action == "new") {
				$('#change_head_btn').hide();
				$('#id_card_a').hide();
				$('#id_card_b').hide();
				var url1 = "<c:url value='/user/source/'></c:url>" + orgNo;
				Source.load(url1);
				/* var url2 = "<c:url value='/common/type/source_type'></c:url>";
				mini.get("SourceType").load(url2);
				var url3 = "<c:url value='/common/type/employ_type'></c:url>";
				mini.get("EmployType").load(url3); */
				var o = new Object();
				o.OrgNo = orgNo;
				o.OrgName = orgName;
				form.setData(o);
				dataOri = o;
				return;
			}
			if(action == "check"){
				$('#change_head_btn').hide();
				$('#id_card_a').hide();
				$('#id_card_b').hide();
			}
			/* CardID.disable();
			Source.disable(); */
			var messageid = mini.loading("获取中...", "Loading");
			var urlBase = '<c:url value="/user/form/"></c:url>' + id;
			$.ajax({
				url : urlBase,
				type : "get",
				dataType : 'json',
				success : function(text) {
					if (!text) {
						return;
					}
					var o = mini.decode(text);
					var url1 = "<c:url value='/user/source/'></c:url>" + o.OrgNo;
					Source.load(url1);
					var photoUrl = o.UserPhoto;
					if(photoUrl){
						$("#imgUrl").attr("src",fileServer + photoUrl);
					}else{
						$("#imgUrl").attr("src","<c:url value='/share/images/photo_2.jpg'></c:url>");
					}
					var cardA = o.CardA;
					if(cardA){
						$("#imgUrlA").attr("src",fileServer + cardA);
					}else{
						$("#imgUrlA").attr("src","<c:url value='/share/images/id_cardA_2.jpg'></c:url>");
					}
					var cardB = o.CardB;
					if(cardB){
						$("#imgUrlB").attr("src",fileServer + cardB);
					}else{
						$("#imgUrlB").attr("src","<c:url value='/share/images/id_cardB_2.jpg'></c:url>");
					}
					form.setData(o);
					dataOri = o;
					labelModel(form);
				},
				complete : function(XMLHttpRequest, textStatus) {
					mini.hideMessageBox(messageid);
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {

				}
			});
		}
		function packData() {
			return form;
		}
		function parentChanged() {
			var value = ParentName.getValue();
			var object = value.split('serverSplit');
			ParentNo.setValue(object[0]);
		}
		//添加头像
		function addPhoto(){
			if(action == "new"){
				top.commonTools.showTip("请保存信息后再上传照片！", 2);
				return;
			}
			$('#fileId').fileupload({
				dataType : 'html',//数据类型：json
				url : rootPath + 'attach/upload/file/无/photo/'+cardId,//上传地址
				formData : {
					name : 'file'
				},
				add : function(e, data) {
					data.submit();
				},
				done : function(e, data) {
					var param = successDataTransform(data.result);
					if (param.isSuccess) {
						$("#imgUrl").attr("src",
								fileServer + param.errorInfo);
					}
				}
			});
		}
		// 修改头像
		$("#change_head_btn").click(function() {
			$('#fileId').fileupload({
				dataType : 'html',//数据类型：json
				url : rootPath + 'attach/upload/file/无/UserPhoto/'+cardId,//上传地址
				formData : {
					name : 'file'
				},
				add : function(e, data) {
					data.submit();
				},
				done : function(e, data) {
					var param = successDataTransform(data.result);
					if (param.isSuccess) {
						$("#imgUrl").attr("src",fileServer + param.errorInfo);
					}
				}
			});
		});
		// 身份证正面
		$("#id_card_a").click(function() {
			$('#fileIdA').fileupload({
				dataType : 'html',//数据类型：json
				url : rootPath + 'attach/upload/fileA/无/CardA/'+cardId,//上传地址
				formData : {
					name : 'fileA'
				},
				add : function(e, data) {
					data.submit();
				},
				done : function(e, data) {
					var param = successDataTransform(data.result);
					if (param.isSuccess) {
						$("#imgUrlA").attr("src",fileServer + param.errorInfo);
					}
				}
			});
		});
		// 身份证反面
		$("#id_card_b").click(function() {
			$('#fileIdB').fileupload({
				dataType : 'html',//数据类型：json
				url : rootPath + 'attach/upload/fileB/无/CardB/'+cardId,//上传地址
				formData : {
					name : 'fileB'
				},
				add : function(e, data) {
					data.submit();
				},
				done : function(e, data) {
					var param = successDataTransform(data.result);
					if (param.isSuccess) {
						$("#imgUrlB").attr("src",fileServer + param.errorInfo);
					}
				}
			});
		});
		// 修改密码
		$("#change_psw_btn").click(function() {
			var url = "<c:url value='/user/infor/psw' />";
			mini.open({
				url : url,
				title : "修改密码",
				width : 400,
				height : 300,
				onload : function() {
					/* var iframe = this.getIFrameEl();
					var data = {
					}; */
					//iframe.contentWindow.SetData(data);
				},
				ondestroy : function(action) {
					if (action == 'ok') {
						parent.mini.confirm("密码修改成功。是否重新登录？", "是", function(
								action) {
							if (action == "ok") {
								parent.location = "<c:url value='/login/logout' />"
							} else {
							}
						});
					}
				}
			});
			
			$('#fileIdB').fileupload({
				dataType : 'html',//数据类型：json
				url : rootPath + 'attach/upload/fileB/无/CardB/'+cardId,//上传地址
				formData : {
					name : 'fileB'
				},
				add : function(e, data) {
					data.submit();
				},
				done : function(e, data) {
					var param = successDataTransform(data.result);
					if (param.isSuccess) {
						$("#imgUrlB").attr("src",fileServer + param.errorInfo);
					}
				}
			});
		});
		/* form查看模式 */
		function labelModel(_form) {
			var fields = _form.getFields();
			for (var i = 0, l = fields.length; i < l; i++) {
				var c = fields[i];
				if (c.setReadOnly)
					c.setReadOnly(true);
				if (c.setIsValid)
					c.setIsValid(true);
				if (c.addCls)
					c.addCls("asLabel");
			}
		}
	</script>
</body>
</html>